<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <title>权限组</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta name="robots" content="noindex,nofollow" />
  <link rel="stylesheet" href="__PUBLIC__/layui/css/layui.css" media="all">
  <link rel="stylesheet" href="__PUBLIC__/font-awesome/css/font-awesome.min.css" media="all" />
  <link rel="stylesheet" href="__CSS__/common.css" media="all">
  <style>
    tr {
      height: 40px;
      line-height: 40px;
      color: #5F6E82;
      font-size: 14px;
    }

    .layui-btn-group .layui-btn.btn-edit {
      margin-right: 10px !important;
    }

    td>a:only-child {
      color: #559FF0 !important;
    }
  </style>
</head>

<body class="page-body">
  <h2 class="comm-title">权限组</h2>
  <div class="layui-tab">
    <ul class="layui-tab-title page-tab-title">
      <li class="layui-this">角色管理</li>
      <li><a href="{:url('admin/admin/adminCatePublish')}">新增角色</a></li>
    </ul>
  </div>
  <div class="tpcms-body-div page-main">
    <!-- 搜索 -->
    <div class="layui-form-item">
      <div class="layui-input-inline">
        <input type="text" name="keywords" lay-verify="title" autocomplete="off" placeholder="请输入关键词" class="layui-input layui-btn-sm">
      </div>
      <div class="layui-input-inline">
        <div class="layui-inline">
          <div class="layui-input-inline">
            <input type="text" class="layui-input" id="create_time" autocomplete="off" placeholder="创建时间" name="create_time">
          </div>
        </div>
      </div>
      <button class="layui-btn layui-btn-danger layui-btn-sm search-btn" lay-submit="" lay-filter="serch">搜索</button>
    </div>
    <!-- end 搜索 -->
    <div class="page-table">
      <table class="layui-hide" id="sm" lay-filter="sm"></table>
    </div>

    <script type="text/html" id="preview">
	       <a href="javascript:;" onclick="openLayer('{:url('admin/admin/preview')}?id={{d.id}}')" class="preview" style="margin-right: 0;font-size:12px;">点击查看</a>
	  </script>
    <script type="text/html" id="barDemo">
        <a href="{:url('admin/admin/adminCatePublish')}?id={{d.id}}" class="layui-btn layui-btn-xs a_menu layui-btn-primary btn-edit">编辑</a>
        {{#  if(d.id != 1){ }}
        <a class="layui-btn layui-btn-xs layui-btn-primary delete btn-cancel" onclick="del({{d.id}})" >删除</a>
        {{#  } }}
	  </script>
    <script src="__PUBLIC__/jquery/jquery.min.js"></script>
    <script src="__PUBLIC__/layui/layui.js"></script>
    <script type="text/javascript">
      // 删除
      function del(id) {
        layer.confirm('确定要删除?', function (index) {
          $.ajax({
            url: "{:url('admin/admin/adminCateDelete')}",
            data: { id: id },
            success: function (res) {
              layer.msg(res.msg);
              if (res.code == 1) {
                setTimeout(function () {
                  location.href = res.url;
                }, 1500)
              }
            }
          })
        })
      }
      // 查看权限
      function openLayer(url) {
        layer.open({
          title: false,
          type: 2,
          content: url,
          area: ['45%', '90%']
        });
        return false;
      }

      layui.use(['table','laydate'], function () {
        var table = layui.table,
        laydate = layui.laydate,
        form = layui.form;
        cons = [
          [{ type: 'numbers', width: "5%", fixed: 'left', title: '序号' },
          { field: 'name', width: "6%", title: '角色名称' },
          { field: '', width: "6%", templet: '#preview', title: '权限预览' },
          { field: 'create_time', width: "12%", title: '创建时间' },
          { field: 'update_time', width: "12%", title: '最后修改时间' },
          { field: 'desc', width: "15%", title: '备注' },
          { fixed: 'right', width: "8%", toolbar: '#barDemo', title: '操作' }
          ]
        ];

        laydate.render({
          elem: '#create_time' //指定元素
        });

        table.render({
          elem: '#sm',
          url: "{:url('admin/admin/ajaxadminCate')}",
          cellMinWidth: 80,
          cols: cons,
          page: true,
          limit: 30
        });

        form.on('submit(serch)', function (data) {
          var table = layui.table,
          form = layui.form;
          var time = $('#create_time').val();
          var keywords = $('[name=keywords]').val();
          table.render({
            elem: '#sm',
            url: "{:url('admin/admin/ajaxadminCate?time=')}" + time + '&keywords=' + keywords,
            cellMinWidth: 80,
            cols: cons,
            page: true,
            limit: 30,
          });
        });


      })
    </script>
    
  </div>
</body>

</html>